#include "./build.h"

#ifdef BUILD_APP

#include "./task/app_task.h"
using namespace task;

int main() {
    osKernelInitialize();
    appTask.start();
    osKernelStart();
}

#endif

#ifdef BUILD_BOOT

#include "./cfg/ota_info.h"
#include "./xlib/compat.h"
#include "./utils/core.h"

using namespace cfg;
using namespace driver;
using namespace utils;

int main() {
    if (otaInfo.verify() && otaInfo->verify()) {
        Error err = flash::erase(
            otaInfo->app_addr,
            otaInfo->pkg_size
        );

        err = flash::write(
            otaInfo->app_addr,
            reinterpret_cast<const void *>(otaInfo->ota_data_addr),
            otaInfo->pkg_size
        );
 
        otaInfo->reset();
    }
    core::run_process(flash::APP_ADDR);
}

#endif
